#!/usr/bin/env python
# -*- coding: utf-8 -*-
import flask_restful as restful
from flask import (
    request,
    abort
)
from bd.utils.permission import require_admin_login


class BaseView(restful.Resource):
    resp = dict(
        code=0,
        message=u'success'
    )

    def dispatch_request(self, *args, **kwargs):
        self.resp = dict(
            code=0,
            message=u'success'
        )
        request_method = request.method
        # method = require_admin_login(getattr(self, request_method.lower()))(*args, **kwargs)
        method = getattr(self, request_method.lower())(*args, **kwargs)
        return method

    def get(self, *args, **kwargs):
        abort(405)

    def post(self, *args, **kwargs):
        abort(405)

    def delete(self, *args, **kwargs):
        abort(405)

